from django.db import models
from django.utils import timezone


class StorageInstanceRecord(models.Model):
    """
    存储实例记录
    """
    create_uid = models.IntegerField(
        default=0,
        verbose_name='创建记录用户ID'
    )
    create_date = models.DateTimeField(
        default=timezone.now,
        verbose_name='创建时间'
    )

    storage_instance_id = models.IntegerField(
        default=0,
        verbose_name='实例ID'
    )
    name = models.CharField(
        default='',
        max_length=50,
        verbose_name='名称'
    )
    type = models.IntegerField(
        default=1,
        verbose_name='类型'
    )
    endpoint = models.CharField(
        default='',
        max_length=200,
        verbose_name='endpoint'
    )
    accessKeyID = models.CharField(
        default='',
        max_length=200,
        verbose_name='accessKeyID'
    )
    accessKeySecret = models.CharField(
        default='',
        max_length=200,
        verbose_name='accessKeySecret'
    )

    class Meta:
        verbose_name = "存储实例记录"
        verbose_name_plural = "存储实例记录 - (StorageInstanceRecord)"

    def __str__(self):
        return self.name


class DBInstanceRecord(models.Model):
    """
    DB实例记录
    """
    create_uid = models.IntegerField(
        default=0,
        verbose_name='创建记录用户ID'
    )
    create_date = models.DateTimeField(
        default=timezone.now,
        verbose_name='创建时间'
    )

    db_instance_id = models.IntegerField(
        default=0,
        verbose_name='DB实例ID'
    )
    name = models.CharField(
        default='',
        max_length=50,
        verbose_name='name'
    )
    host = models.CharField(
        default='',
        max_length=50,
        verbose_name='host'
    )
    username = models.CharField(
        default='',
        max_length=50,
        verbose_name='username'
    )
    password = models.CharField(
        default='',
        max_length=50,
        verbose_name='password'
    )
    database_name = models.CharField(
        default='',
        max_length=50,
        verbose_name='database_name'
    )

    class Meta:
        verbose_name = "DB实例记录"
        verbose_name_plural = "DB实例记录 - (DBInstanceRecord)"

    def __str__(self):
        return self.name
